"[object Object]" passed instead of the actual object as parameter
Posted
by
Andrew Latham
on Stack Overflow
See other posts from Stack Overflow
or by Andrew Latham
Published on 2012-10-01T03:34:33Z
Indexed on
2012/10/01
3:37 UTC
Read the original article
Hit count: 314
I am using Heroku with a Ruby on Rails application, and running from Safari. I have the following Ajax call:
$.ajax({
type : 'POST',
url : '/test_page',
data : {stuff: arr1},
dataType : 'script'
});
arr1
is supposed to be an array of objects. There's a console.log
right before that, and it is:
[Object, Object, Object, Object, Object, ...]
However, I got an error on the server side when I made this ajax call. The logs showed
2012-10-01T03:13:34+00:00 app[web.1]: Parameters: {"stuff"=>"[object Object]"}
2012-10-01T03:13:34+00:00 app[web.1]: WARNING: Can't verify CSRF token authenticity
2012-10-01T03:13:34+00:00 app[web.1]: NoMethodError (undefined method `to_hash' for "[object Object]":String):
2012-10-01T03:13:34+00:00 app[web.1]: Completed 500 Internal Server Error in 1ms
I'm unable to replicate the error. It's really confusing to me - what would cause that string to sometimes be passed to the server instead of the object?
© Stack Overflow or respective owner